package itheima.zuoye.Test9;

import java.util.Random;
import java.util.TreeSet;

public class test {
    // 生成8个10-20的随机数，要求随机数不能重复
    public static void main(String[] args) {
        Random r = new Random();
        TreeSet<Integer> c = new TreeSet<>();
        while (c.size() < 8) {
            int i = r.nextInt(11) +10 ;
            c.add(i);
            System.out.println("第"+c.size()+"次生成的随机数是："+i);
        }
        System.out.println("集合中保存的8个不重复的随机数是："+c);

    }
}
